package com.锁;

import java.util.concurrent.locks.ReentrantReadWriteLock;

public class demo01 {



    public static void main(String[] args) {

        T t = new T();

        for(int i = 0 ; i < 100 ; i++) {

            new Thread(t).start();
        }


    }




}
class T implements Runnable{
    ReentrantReadWriteLock reentrantReadWriteLock  = new ReentrantReadWriteLock();


    private int i =0;


    @Override
    public void run() {
        reentrantReadWriteLock.writeLock().lock();
        for(int a =  0 ; a <100; a++){

            i++;
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
        reentrantReadWriteLock.writeLock().unlock();
    }
}